<template>
  <div>
    <!-- <p v-if="this.$store.state.shopm.arr.length==0">请等待</p> -->
    <!-- {{this.$store.state.shopm.arr[0].coffee}} -->
    <!-- <span v-else>{{this.$store.state.shopm.arr[0].coffee[0].coffee_first_price}}</span> -->
 
    <!-- <h1 v-if="this.$store.state.shopm.arr.length!=0">{{this.$store.state.shopm.arr[0].coffee[0].coffee_first_price}}</h1> -->
    
      <van-swipe-cell v-if="this.$store.state.shopm.arr.length!=0">
  <van-card
     :num="text"
    :price="this.$store.state.shopm.arr[0].coffee[0].coffee_first_price"
    :title="this.$store.state.shopm.arr[0].coffee[0].coffee_name"
    class="goods-card"
    thumb="https://img01.yzcdn.cn/vant/cat.jpeg"
  >
  
   <template #tags>
    <van-tag plain type="danger">半糖</van-tag>
    <van-tag plain type="danger">少冰</van-tag>
  </template>
  <template #footer>
    <van-button size="mini" v-on:click="fun()"><h2>-</h2></van-button>
    <van-button size="mini" v-on:click="hun()"><h2>+</h2></van-button>
  </template>
</van-card>
</van-swipe-cell>
  </div>
</template>

<script>
import eventbus from"@/components/eventbus/eventbus.js"
export default {

  created(){
        // console.log(this.$store.state.shopm.arr.length!=0)
  },
    methods:{
      fun(){
        if(this.text>0){
            this.text-=1
            eventbus.$emit("xiaoming",this.text)
        }
       
      },
      hun(){
    
            this.text+=1
        eventbus.$emit("xiaoming",this.text)
       
      }

    },

  data(){
    return {
      bool:false,
      text:1
    }
  },
   mounted() {
    //使用vuex发送异步请求---->dispatch触发actions发送异步
    // this.$store.dispatch("shopData",{url:"/coffee-shop"}),
     this.$store.dispatch("shopData",{url:"http://81.68.226.70:8050/coffee/"}).then(()=>{
      // this.bool=true
     })
      
  },
  computed:{
    // newstore(){
  
    //   if(this.$store.state.shopm.arr.length!=0){
    //     console.log(1111111)
    //     return this.$store.state.shopm.arr
    //   }
    //   return false
     
    // }
  }
 
}

</script>

<style scoped>
  .goods-card {
    margin: 0;
    background-color: white;
  }

  .delete-button {
    height: 100%;
  }
</style>